const baseUrl = "/video-analysis";
import { apiClient, ApiListResponse } from "../lib/api";

export interface GetParams {
  pageSize: number;
  pageNum: number;
}

export const getAnalysisList = async (
  data: GetParams
): Promise<ApiListResponse<any>> => {
  return await apiClient.getList<any>(`${baseUrl}/list`, { params: data });
};

export const getAnalysisItem = async (id: string) => {
  return await apiClient.get(`${baseUrl}/${id}`);
};

export const addAnalysis = async (videoLink: string, language: string) => {
  return await apiClient.post(`${baseUrl}/add`, { videoLink, language });
};

export const reAnalysis = async (id: string) => {
  return await apiClient.post(`${baseUrl}/reanalysis/${id}`);
};

export const downloadAnalysis = async (id: string) => {
  return await apiClient.download(
    `${baseUrl}/export/${id}`,
    {},
    `${id}_${new Date().getTime()}.xlsx`
  );
};

export const delAnalysis = async (id: string) => {
  return await apiClient.post(`${baseUrl}/delete/${id}`);
};
